package com.bw.liuyushan.zhuangao4_weektest2.Utils;

import com.bw.liuyushan.zhuangao4_weektest2.RequestApi.APIGift;
import com.bw.liuyushan.zhuangao4_weektest2.RequestApi.APIUser;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * ZhuanGao4_WeekTest2
 * file name is : VideoRxJavaManager
 * created by Ender on 2021/8/23 8:35.
 * author : 刘雨杉
 * Describe(作用):
 */
public class GiftRxJavaManager {
    public GiftRxJavaManager() {
    }
    private static GiftRxJavaManager giftRxJavaManager;

    public static GiftRxJavaManager getInstance() {
        if (giftRxJavaManager==null){
            giftRxJavaManager=new GiftRxJavaManager();
        }
        return giftRxJavaManager;
    }
    private Retrofit retrofit;

    public Retrofit getRetrofit() {
        if (retrofit==null){
            retrofit=new Retrofit.Builder()
                    .baseUrl(APIGift.url)
                    .addConverterFactory(GsonConverterFactory.create())
                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                    .client(new OkHttpClient.Builder()//添加网络拦截器
                            .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
                            .build())
                    .build();
        }
        return retrofit;
    }
}
